{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test of the weird printing rules for the `gsym` argument to `Ga`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Constructed without the galgebra printer enabled"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from galgebra.ga import Ga\n",
    "from sympy import symbols, init_printing\n",
    "from IPython.display import display\n",
    "init_printing(use_latex='mathjax')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "coords = symbols('u v', real=True)\n",
    "f = Ga('e*u|v', gsym='f')\n",
    "g = Ga('e*u|v', gsym='g')\n",
    "fc = Ga('e*u|v', coords=coords, gsym='f')\n",
    "gc = Ga('e*u|v', coords=coords, gsym='g')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Printed with the default printer. Note that sympy shows determinants with $|M|$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{f}\\right|$"
      ],
      "text/plain": [
       "-│f│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{g}\\right|$"
      ],
      "text/plain": [
       "-│g│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{f{\\left(u,v \\right)}}\\right|$"
      ],
      "text/plain": [
       "-│f(u, v)│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{g{\\left(u,v \\right)}}\\right|$"
      ],
      "text/plain": [
       "-│g(u, v)│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(f.e_sq)\n",
    "display(g.e_sq)\n",
    "display(fc.e_sq)\n",
    "display(gc.e_sq)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Printed within an Mv. Note that galgebra's default printer shows determinants with $\\det (M)$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( f\\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(f)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( g\\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(g)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( f {\\left (u,v \\right )}\\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(f)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( g {\\left (u,v \\right )}\\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(g)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(f.mv(f.e_sq))\n",
    "display(g.mv(g.e_sq))\n",
    "display(fc.mv(fc.e_sq))\n",
    "display(gc.mv(gc.e_sq))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Constructed with the printer enabled"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from galgebra.printer import Format\n",
    "Format()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "coords = symbols('u v', real=True)\n",
    "fp = Ga('e*u|v', gsym='f')\n",
    "gp = Ga('e*u|v', gsym='g')\n",
    "fcp = Ga('e*u|v', coords=coords, gsym='f')\n",
    "gcp = Ga('e*u|v', coords=coords, gsym='g')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Printed with the non-galgebra printer."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{f}\\right|$"
      ],
      "text/plain": [
       "-│f│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{g}\\right|$"
      ],
      "text/plain": [
       "-│g│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{f{\\left(u,v \\right)}}\\right|$"
      ],
      "text/plain": [
       "-│f(u, v)│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left|{g{\\left(u,v \\right)}}\\right|$"
      ],
      "text/plain": [
       "-│g(u, v)│"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(fp.e_sq)\n",
    "display(gp.e_sq)\n",
    "display(fcp.e_sq)\n",
    "display(gcp.e_sq)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Printed within an Mv - now also consistent. Note that the galgebra `Format` does not show function arguments in its default setting."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( f\\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(f)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( g\\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(g)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( f \\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(f)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "\\begin{equation*} - \\det\\left ( g \\right ) \\end{equation*}"
      ],
      "text/plain": [
       "-Determinant(g)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(fp.mv(fp.e_sq))\n",
    "display(gp.mv(gp.e_sq))\n",
    "display(fcp.mv(fcp.e_sq))\n",
    "display(gcp.mv(gcp.e_sq))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
